package controllers;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class ConnectToServer {

	static Socket server;
	private static OutputStream out;
	private static InputStream in;
	private static BufferedReader br;
	
	public static void connectToServer(String host, int port)
			throws ConnectionFailureException {
		try {
			//System.out.println("Connecting...");
			server = new Socket(host, port);
			//System.out.println("Connected");
			in = server.getInputStream();
			out = server.getOutputStream();
			InputStreamReader isr = new InputStreamReader(in);
			br = new BufferedReader(isr);
		} catch (UnknownHostException e) {
			//System.out.println("Unknown Host");
			throw new ConnectionFailureException();
		} catch (IOException e) {
			//System.out.println("IO Connection failure");
			throw new ConnectionFailureException();
		}
	}

}
